//
//  InfoViewController.m
//  极客闪讯
//
//  Created by LIMING on 14-10-15.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "InfoViewController.h"

@interface InfoViewController ()

@end

@implementation InfoViewController
- (void)dealloc
{
    [_topScroll release];
    [super dealloc];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        [self createScrollView];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"极客闪讯";
        
//    [self createScrollView];//调用创建滚动视图方法
}
#pragma mark
#pragma mark  创建顶部滚动菜单(scrollview)
- (void)createScrollView
{
    self.topScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
    _topScroll.contentSize = CGSizeMake(1440, 30);//设置滚动视图偏移量
    _topScroll.backgroundColor = [UIColor redColor];
//    _topScroll.delegate = self;
    _topScroll.scrollEnabled = YES;
//    _topScroll.alwaysBounceHorizontal = YES;
    _topScroll.showsHorizontalScrollIndicator = NO;//不显示横向滚动条
    [_topScroll setPagingEnabled:YES];//允许整页滚动
    
    //用一个数组来存放导航button标题
    NSArray *array = @[@"头条",@"DIY",@"摄像机",@"直播",@"平板",@"MID",@"电视",@"超极本",@"家电",@"笔记本",@"测评",@"新闻",@"iPhone",@"企业",@"导购",@"行情",@"相机",@"手机"];
    //创建18个button加入到scrollview里
    for(int i = 0; i < 18; i++)
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(80 * i, 0, self.topScroll.contentSize.width / 18, self.topScroll.contentSize.height);
        [button setTitle:array[i] forState:UIControlStateNormal];
        [button setTag:i + 1];
        if(button.tag % 2 == 0)
        {
            button.backgroundColor = [UIColor blueColor];
        }
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [_topScroll addSubview:button];
    }
    [self.view addSubview:_topScroll];
    [_topScroll release];
}
- (void)buttonAction:(UIButton *)sender
{
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"滚动");
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
